import Person from "./interface1";

// interface ResultConstructor<T> {
//   new (): ResultInterface<T>;
// }

// interface ResultInterface<T> {
//   msg: string;
//   code: number;
//   data: T;
// }

class Result<T> {
  private data: T;
  private msg: string;
  private code: number;
  constructor(code: number, msg: string, data: T) {
    this.code = code;
    this.msg = msg;
    this.data = data;
  }

  public static success<T>(data: T, msg?: string) {
    return new Result<T>(200, msg || "success", data);
  }
}

const result = new Result<string>(200, "Hello", "yes");

class Student extends Person {
  className: number;
  Grade: number;
  constructor(name: string, c: number, g: number) {
    super(name);
    this.Grade = g;
    this.className = c;
  }
}

const res: Result<Student> = Result.success<Student>(new Student("xiaohong", 3, 2));
console.log(res);
